<template>
    <a-card :bordered="false">
        <div class="table-operator">
             <a-button v-if="selectedRowKeys.length > 0" style="margin-left: 8px" @click="batchDel">
                批量操作
            </a-button>
        
        </div>
        <LTable
            ref="cronLogList"
            size="small"
            rowKey="keyId"
            :formAttributes="formAttributes"
            :columns="columns"
            axiosUrl="/SysCronLogController/page"
            :initQuery="initQuery"
            :showPagination="true"
            :showQueryForm="true"
            :rowSelection="{onChange:onSelectChange}"
        >
        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record,'cronLogForm',record.taskName)">详情</a>
        </span>
        
    </LTable>
    <cronLogForm ref="cronLogForm" @close="refresh('cronLogList')" @ok="refresh('cronLogList')"></cronLogForm> 
    </a-card>
</template>

<script>
import LTable from '@/components/lt/LTable'
import cronLogForm from './cronLogForm'
import defaultSettings from '@/config/defaultSettings'
import {SysMixin} from '@/mixins/SysMixin'
import request from '@/utils/request'
export default {
    name:'cronLogList',
    components:{
       LTable,cronLogForm
    },
    mixins:[SysMixin],
    data(){
        return{
            formAttributes:[
                {field:'taskName',label:'任务名称',component:'input',condition:'like'},
                {field:'beginTime',label:'执行时间',component:'time',condition:'between'},
                {field:'taskState',label:'执行结果',component:'input',condition:'like'},
            ],
            initQuery:[{field:'systemNo',val:defaultSettings.systemNo}],
            columns:[
                {
                    title: '序号',
                    dataIndex: '',
                    key:'rowIndex',
                    width:60,
                    align:"center",
                    customRender:function (t,r,index) {
                      return parseInt(index)+1;
                    }
                },
                
                {
                    title: '任务名称',
                    dataIndex: 'taskName'
                },
                {
                    title: '系统编号',
                    dataIndex: 'systemNo'
                    
                },
                {
                    title: '开始时间',
                    dataIndex: 'beginTime'
                },
                {
                    title:'结束时间',
                    dataIndex:'endTime'
                },
                {
                    title: '执行结果',
                    dataIndex: 'taskState',
                },
                {
                    title: '操作',
                    dataIndex: 'action',
                    width: '120px',
                    scopedSlots: { customRender: 'action' }
                }
            ],
            selectedRowKeys:[],
        }
    },
    created(){
       
    },
    methods:{
        onSelectChange (selectedRowKeys, selectedRows) {
            this.selectedRowKeys = selectedRowKeys
        },
        batchDel(){
            if(this.selectedRowKeys.length>0){
                request.get('/SysCronLogController/batchDel',{params:{keyIds:this.selectedRowKeys.join(",")}}).then((res)=>{
                    if (res.success) {
                        this.$message.success(res.message)
                        this.refresh('cronLogList')
                        this.selectedRowKeys=[]
                    } else {
                        this.$message.warning(res.message);
                    }
                })
            }
        }
        
    }
}
</script>